package com.loster.login.service;

import com.loster.login.model.LoginReq;
import com.loster.login.model.LoginResp;
import com.loster.login.strategy.UserGranter;
import com.loster.login.strategy.UserLoginFactory;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Resource
    private UserLoginFactory factory;

    public LoginResp login(LoginReq loginReq){
        UserGranter granter = factory.getGranter(loginReq.getType());
        if(granter == null){
            LoginResp resp = new LoginResp();
            resp.fail("登录失败");
            return  resp;
        }
        return granter.login(loginReq);
    }

}
